<template>
	<view class="search xflex-x-between">
		<!-- <image class="search-icon xmr24" @click="uplod" src="/static/image/home_icon_ss.png" mode=""></image> -->
		<view class="" @click="scana()" v-if="leftShow">
			<u-icon name="camera" color="#333" size="28"></u-icon>
		</view>
		<view class="xflex1 xflex-x">
			<input class="search-iput xflex1" v-model="config" type="text" :placeholder="placeholder" />
			<image @click="del()" style="width: 48rpx; height: 48rpx;padding-right: 20rpx;"
				class="select_val_icon xmr12" src="/static/image/icon_qx.png" mode=""></image>
		</view>
		<view class="search-btn" @click="search()">
			搜索
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				config: '',

			}
		},
		props: {
			keyword: {
				default: ''
			},
			leftShow:{
				default:true
			},
			placeholder:{
				default: '请以图搜图或输入关键词'
			}
		},
		watch: {
			keyword: {
				handler(newVal) {
					console.log(newVal,"=");
					this.config = newVal
				},
				deep: true,
				immediate:true
			}
		},
		methods: {
			search() {
				console.log("ee");
				this.$emit('search', this.config)
			},
			del() {
				console.log("==");
				this.config = ''

				this.$emit('search', this.config)
			},
			scana() {
				this.$emit("scan")
			}


		},
		// props: ['value'], //接收一个 value prop
		// computed: {
		// 	config: {
		// 		get() {
		// 			return this.value
		// 		},
		// 		set(val) {
		// 			console.log(val);
		// 			this.$emit('input', val)
		// 		}
		// 	}
		// }

	}
</script>

<style lang="scss" scoped>
	.search {
		// width: 690rpx;
		// height: 68rpx;
		background: #EEEEEE;
		border-radius: 34rpx;
		padding: 20rpx 10rpx 20rpx 28rpx;
		box-sizing: border-box;

		&-icon {
			width: 40rpx;
			height: 40rpx;
		}

		&-iput {
			font-size: 32rpx;
			font-weight: 500;
			color: #AAAAAA;
		}

		&-btn {
			width: 104rpx;
			height: 68rpx;
			background: #3F7233;
			border-radius: 24rpx;
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			text-align: center;
			line-height: 68rpx;
		}
	}
</style>